class TagsController < ApplicationController

  def reload
    feeds = Feed.find(:all)
    feeds.each do |feed|
      feed.posts.each do |post|        
        tags = post.body.scan(/\A[а-яА-я\s,]*/)          
        post.tag_with(tags[0]) unless tags.nil?
      end
    end
    render :partial => "tags", :object => Tag.find(:all)
  end
  
  def create
    tag = Tag.new(:name => params[:tag_name])
    tag.save
    @tags = Tag.find(:all)
    render :partial => "tags", :object => @tags
  end

  def destroy
    tag = Tag.find_by_name params[:id]
    tag.destroy
    @tags = Tag.find(:all)
    render :partial => "tags", :object => @tags
  end
  
end
